﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public static class ChancesDAL
    {
        public static Users Login(string ChanName, string ChanLinkMan, string ChanCreateMan, string ChanDueMan)
        {
            //准备参数
            SqlParameter[] pars = new SqlParameter[4];
            pars[0] = new SqlParameter("@ChanName", ChanName);
            pars[1] = new SqlParameter("@ChanLinkMan", ChanLinkMan);
            pars[2] = new SqlParameter("@ChanCreateMan", ChanCreateMan);
            pars[3] = new SqlParameter("@ChanDueMan", ChanDueMan);
            //获取查询的值
            string str1 = "ChanName like @ChanName and ";
            string str2 = "ChanLinkName like @ChanLinkMan and ";
            string str3 = "ChanCreateName like @ChanCreateMan and ";
            string str4 = "ChanDueName like @ChanDueMan";
            //执行查询
            string sql = "select * from V_Chances where " + str1 + str2 + str3 + str4;
            List<Users> list = BaseDAL.Select<Users>(sql, pars);
            //返回结果
            if (list.Count > 0)
                return list[0];
            else
                return null;

        }
    }
}
